import request from '@/utils/request';

export function getLinkdoodSetting(data) {
  return request({
    url: '/api/enterprise/linkdood/setting',
    method: 'get',
  });
}

export function saveLinkdoodSetting(data) {
  return request({
    url: '/api/enterprise/linkdood/setting',
    method: 'post',
    data,
  });
}

export function connectTest(thirdPartyId, data) {
  return request({
    url: `/api/thirdparties/${thirdPartyId}/connectivity`,
    method: 'post',
    data,
  });
}

export function getRoles(data) {
  return request({
    url: '/api/custom-roles/',
    method: 'get',
    params: data,
  });
}

export function saveRole(data, id) {
  if (id) {
    return request({
      url: `/api/custom-roles/${id}`,
      method: 'patch',
      data,
    });
  }
  return request({
    url: `/api/custom-roles/`,
    method: 'post',
    data,
  });
}

export function getRoleById(id) {
  return request({
    url: `/api/custom-roles/${id}`,
    method: 'get',
  });
}

export function deleteRoleInfo(id) {
  return request({
    url: `/api/custom-roles/${id}`,
    method: 'delete',
  });
}

export function getThirdpartiesList() {
  return request({
    url: `/api/thirdparties/`,
    method: 'get',
  });
}

export function getThirdpartyById(id) {
  return request({
    url: `/api/thirdparties/${id}`,
    method: 'get',
  });
}

export function modifyThirdpartyById(id, data) {
  return request({
    url: `/api/thirdparties/${id}`,
    method: 'patch',
    data,
  });
}

export function getServiceInfo() {
  return request({
    url: `/api/system/service/config`,
    method: 'get',
  });
}

// 获取菜单列表
export function treeSelect() {
  return request({
    url: `/api/menu/treeselect`,
    method: 'get',
  });
}

// 列表回显
export function roleMenuTreeSelect(roleId) {
  return request({
    url: `/api/menu/roleMenuTreeselect/` + roleId,
    method: 'get',
  });
}

